package top.huhuiyu.spirngboot2.total.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.huhuiyu.spirngboot2.total.anno.Limit;
import top.huhuiyu.spirngboot2.total.base.BaseDataResult;
import top.huhuiyu.spirngboot2.total.base.BaseResult;
import top.huhuiyu.spirngboot2.total.entity.TbUser;
import top.huhuiyu.spirngboot2.total.service.AuthService;
import top.huhuiyu.spirngboot2.total.vo.UserInfo;

@RestController
@RequestMapping("/auth")
@RequiredArgsConstructor
public class AuthController {
    private final AuthService authService;

    @Limit(key = "login", time = 10 * 1000, message = "登录太频繁")
    @PostMapping("")
    public BaseResult login(@RequestBody TbUser tbUser) {
        return authService.login(tbUser);
    }

    @GetMapping("")
    public BaseDataResult<UserInfo> getUserInfo() {
        return authService.getLoginUser();
    }


}
